<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
	Remove this if you use the .htaccess -->
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<title>企業リスト</title>
	<meta name="description" content="" />
	<meta name="author" content="n" />
	<meta name="viewport" content="width=device-width; initial-scale=1.0" />
	<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
	<link rel="shortcut icon" href="/favicon.ico" />
	<link rel="apple-touch-icon" href="/apple-touch-icon.png" />

<script src="http://code.jquery.com/jquery-1.6.4.js"></script>

<style>
table td{
	padding: 5px;
}
</style>

<?php
	if (isset($_POST["request_type"])){
		//show_error($_POST["request_type"]);
		$request_type = $_POST["request_type"];
	}
	else{
		$request_type = array();
		foreach ($intern_type as $key => $value) {
			array_push($request_type, $key);
		}
	}
	
	$checkall = false;
	if (in_array('0', $request_type)) $checkall = true;
	
	//print_r($request_type);
?>

</head>

<script type="text/javascript">
	
$(document).ready(function(){
  // Your code here
  $("input#allcb").change(function(){
  	$('input:checkbox').attr('checked', $(this).is(':checked') );
  });
  
  $('input:checkbox').not("#allcb").change(function(){
  	if ( !$(this).is(':checked') ) $("input#allcb").attr('checked', false);
  });
});

</script>

<body style="font-family: meiryo,Verdana; font-size: 14px">
	<div>
		<header>
			<h1>企業リスト</h1>
		</header>
		
		<a href="/admin/del_index">削除した企業</a>
		<a href="/admin/logout" style="float: right;">logout</a>
		<div>
			<hr>
			インターン種類:<br>
			<form action="" method="post">
				All<input type="checkbox" name='request_type[]' value="0" id="allcb" <?php if($checkall) echo "checked"?> />&nbsp;&nbsp;
			<?php foreach ($intern_type as $key => $value) {
				echo $value.form_checkbox('request_type[]', $key, in_array($key, $request_type))."&nbsp;&nbsp;";
			}?>
			<input type="submit" value="Go" />
			</form>
			<hr>
		</div>
	</div>
		
	<div>
		<table>
			<tr>
				<th>id</th>
				<th>Name</th>
				<th>Address</th>
				<th>Type</th>
			</tr>
		<?php foreach ($companies as $company) if (check_type_available($company->type, $request_type)){?>
			<tr>
				<td><?php echo $company->id?></td>
				<td><a href="/admin/<?php echo $company->id?>"><?php echo $company->kaisha_mei?></a></td>
				<td><?php echo $company->address?></td>
				<td><?php echo $company->type_name?></td>
				<td nowrap="" style="font-size: 13px">
					<a href="/admin/edit/<?php echo $company->id?>">編集</a>
					<a href="/admin/del/<?php echo $company->id?>" onclick='return confirm("are you sure?")'>削除</a>
				</td>
			</tr>
		<?php }?>
		</table>
		
		<a href="/admin/addnew">追加</a>
	</div>
</body>
</html>
